package com.thread.Demo02;
/*
* 推导lambda表达式
* */
public class TestLambda1 {
    //2.静态内部类
    static class Fun2 implements FunInterface{
        @Override
        public void lambda() {
            System.out.println("Inner: I like lambda!");
        }
    }
    public static void main(String[] args) {
        FunInterface fi = new Fun();
        fi.lambda();

        fi = new Fun2();
        fi.lambda();

        //3.局部内部类
        class Fun3 implements FunInterface{
            @Override
            public void lambda() {
                System.out.println("Inner: function: I like lambda!");
            }
        }

        fi = new Fun3();
        fi.lambda();

        //4.匿名内部类,没有类的名称,借助接口,父类
        fi = new FunInterface(){
            @Override
            public void lambda() {
                System.out.println("Inner:NO Name:I like lambda!");
            }
        };
        fi.lambda();

        //5.用lambda简化,省略了接口和方法名
        fi = () -> {
            System.out.println("lambda simplify :I like lambda!");
        };
        fi.lambda();
    }
}

//定义一个函数式接口
interface FunInterface{
    void lambda();
}

//1.实现类
class Fun implements FunInterface{
    @Override
    public void lambda() {
        System.out.println("I like lambda!");
    }
}
    